package com.lotusfall;

import com.lotusfall.pojo2.Student;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MyTest2 {
    @Test
    public void testStudent1(){
        Student student = new Student();
        System.out.println(student);
    }

    @Test
    public void testStudent2(){
        // 由spring容器进行对象的创建
        // 拖过要从spring容器中去除对象，则要先创建容器对象 ，才能启动获取对象
        ApplicationContext ac  = new ClassPathXmlApplicationContext("s2/applicationContext.xml");
        //Student stu = (Student)ac.getBean("stu");
        System.out.println(ac.getBean("stu"));
    }

    @Test
    public void testStudent3(){
        // 依赖注入
        ApplicationContext ac  = new ClassPathXmlApplicationContext("s3/applicationContext.xml");
        Student stu = (Student)ac.getBean("stu");
        System.out.println(stu);
    }
}
